﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Kmust.Commom
{
    public class KmustPager
    {
            /// <summary>
            /// 每页显示记录数
            /// </summary>
            private int _pageSize = 15;
            /// <summary>
            /// 每页显示记录数
            /// </summary>
            public int PageSize
            {
                get { return _pageSize; }
                set
                {
                    _pageSize = value;
                    GetPageCount();
                }
            }

            private int _nMax = 0;
            /// <summary>
            /// 总记录数
            /// </summary>
            public int NMax
            {
                get { return _nMax; }
                set
                {
                    _nMax = value;
                    GetPageCount();
                }
            }

            private int _pageCount = 0;
            /// <summary>
            /// 页数=总记录数/每页显示记录数
            /// </summary>
            public int PageCount
            {
                get { return _pageCount; }
                set { _pageCount = value; }
            }

            private int _pageCurrent = 0;
            /// <summary>
            /// 当前页号
            /// </summary>
            public int PageCurrent
            {
                get { return _pageCurrent; }
                set { _pageCurrent = value; }
            }

            private void GetPageCount()
            {
                if (this.NMax > 0)
                {
                    this.PageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(this.NMax) / Convert.ToDouble(this.PageSize)));
                }
                else
                {
                    this.PageCount = 0;
                }
            }

    }
}
